<?php
require_once dirname(__FILE__) . '/includes/common.inc.php';

try {
  $hostname = HOST_NAME;
  $username = USER_NAME2;
  $password = PASSWORD2;
  $dbname = DATABASE_NAME2;
  $myPdo = new PDO ('mysql:host=' . $hostname, $username, $password);
  $myPdo->exec('USE ' . $dbname);
  $myPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
  echo $e->getMessage();
}

try {
  $myPdo->exec("ALTER TABLE ns_produce
                  ADD parent_trackId varchar(64)  DEFAULT '',
                  ADD estimates float  DEFAULT '0',
                  ADD extras float  DEFAULT '0',
                  ADD travels decimal(10, 2)  DEFAULT '0.00',
                  
                  ADD createdDate int(16)  DEFAULT '0',
                  
                  ADD sentDate int(16)  DEFAULT '0',
                  ADD receivedDate int(16)  DEFAULT '0',
                  ADD receiver varchar(128)  DEFAULT '',
                  ADD address varchar(512)  DEFAULT '',
                  ADD code varchar(64)  DEFAULT '',
                  ADD company varchar(64)  DEFAULT '',
                  ADD weight float DEFAULT '0',
                  ADD comment varchar(1024)  DEFAULT '',
                  ADD review varchar(1024)  DEFAULT '',
                  
                  ADD pi_trackId varchar(64)  DEFAULT '',
                  ADD pi_sampleId int(11)  DEFAULT '0',
                  ADD pi_name varchar(64)  DEFAULT '',
                  ADD pi_price decimal(10, 2)  DEFAULT '0',
                  ADD pi_unit varchar(64)  DEFAULT '',
                  ADD pi_type varchar(64)  DEFAULT '',
                  ADD pi_model varchar(64)  DEFAULT '',
                  ADD pi_otherId varchar(64)  DEFAULT '',
                  ADD pi_quantity int(11)  DEFAULT '0',
                  ADD pi_total decimal(10, 2)  DEFAULT '0',
                  ADD pi_packageInc varchar(64)  DEFAULT '',
                  
                  ADD user_trackId varchar(64)  DEFAULT '',
                  ADD user_account varchar(64)  DEFAULT '',
                  ADD user_password varchar(64)  DEFAULT '',
                  ADD user_name varchar(64)  DEFAULT '',
                  ADD user_email varchar(64)  DEFAULT '',
                  ADD user_type varchar(64)  DEFAULT '' ");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("ALTER TABLE ns_produceevent
                  ADD produce_trackId varchar(64)  DEFAULT '',
                  ADD targetId int(11)  DEFAULT '0'");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("ALTER TABLE ns_producenote
                  ADD produce_trackId varchar(64)  DEFAULT ''");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("ALTER TABLE ns_producepurchaseitem
                  ADD produce_trackId varchar(64)  DEFAULT ''");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("ALTER TABLE ns_producepurchaseitemselect
                  ADD purchase_trackId varchar(64) DEFAULT ''");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("ALTER TABLE ns_producetrack
                  ADD produce_id int(11)  DEFAULT '0',
                  ADD parent_trackId varchar(64)  DEFAULT '',
                  
                  ADD createdDate int(16)  DEFAULT '0',
                  
                  ADD sentDate int(16)  DEFAULT '0',
                  ADD receivedDate int(16)  DEFAULT '0',
                  ADD receiver varchar(128)  DEFAULT '',
                  ADD address varchar(512)  DEFAULT '',
                  ADD code varchar(64)  DEFAULT '',
                  ADD company varchar(64)  DEFAULT '',
                  ADD weight float DEFAULT '0',
                  ADD comment varchar(1024)  DEFAULT '',
                  ADD review varchar(1024)  DEFAULT '',
                  
                  ADD sourceId int(11)  DEFAULT '0',
                  ADD targetId int(11)  DEFAULT '0',
                  
                  ADD user_trackId varchar(64)  DEFAULT '',
                  ADD user_account varchar(64)  DEFAULT '',
                  ADD user_password varchar(64)  DEFAULT '',
                  ADD user_name varchar(64)  DEFAULT '',
                  ADD user_email varchar(64)  DEFAULT '',
                  ADD user_type varchar(64)  DEFAULT ''");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("ALTER TABLE ns_produceuser
                  ADD produce_id int(11)  DEFAULT '0'");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("CREATE TABLE ns_produceselect (
                  e_oid int(12) AUTO_INCREMENT,
                  trackId varchar(64)  DEFAULT '',
                  produce_trackId varchar(64)  DEFAULT '',
                  title varchar(64)  DEFAULT '',
                  value varchar(64)  DEFAULT '',
                  PRIMARY KEY (e_oid)
               )");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}

try {
  $myPdo->exec("CREATE TABLE ns_producetrackuser (
                  e_oid int(12) AUTO_INCREMENT,
                  trackId varchar(64)  DEFAULT '',
                  track_trackId varchar(64)  DEFAULT '',
                  account varchar(64)  DEFAULT '',
                  password varchar(64)  DEFAULT '',
                  name varchar(64)  DEFAULT '',
                  email varchar(64)  DEFAULT '',
                  type varchar(64)  DEFAULT '',
                  PRIMARY KEY (e_oid)
               )");
} catch (PDOException $e) {
  echo $e->getMessage() . "<br>";
}
?>